package classes
{
	import classes.tfo.StrategyTO;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	
	public class StrategyManager
	{
		private static var instance:StrategyManager = new StrategyManager();
		
		private var tacticsProvider:ArrayCollection = new ArrayCollection();
		
		public var dev_skillProvider:ArrayCollection = new ArrayCollection();
		
		public function StrategyManager()
		{
		}
		
		public function get hasDev_Skill():Boolean {
			return dev_skillProvider.length > 0;
		}
		
		public function setTactics(val:ArrayCollection):void {
			tacticsProvider = val;
		}
		
		public function genTactic(strategyId:int = -1):StrategyTO {
			var strat:StrategyTO = new StrategyTO();
			strat.defaultSkillName = "normal attack";
			strat.defaultSkillRank = 1;
			strategyId = strategyId;
			return strat;
		}
		
		public function copyTacticsList():ArrayCollection {
			var ret:ArrayCollection = new ArrayCollection();
			for(var i:int = 0; i < tacticsProvider.length; i++) {
				ret.addItem(tacticsProvider.getItemAt(i));
			}
			return ret;
		}
		
		public function get tactics():ArrayCollection {
			return tacticsProvider;
		}
		
		public function get tacticsLabelList():ArrayCollection {
			var ret:ArrayCollection = new ArrayCollection();
			for(var i:int = 0; i < tacticsProvider.length; i++) {
				ret.addItem({label:"Tactic " + toRomanNumber(i + 1), tactic:tacticsProvider.getItemAt(i)});
			}
			return ret;
		}
		
		public static function toRomanNumber(num:int):String {
			switch(num) {
				case 1: return "I"; break;
				case 2: return "II"; break;
				case 3: return "III"; break;
				case 4: return "IV"; break;
				case 5: return "V"; break;
				case 6: return "VI"; break;
				case 7: return "VII"; break;
				case 8: return "VIII"; break;
				case 9: return "IX"; break;
				case 10: return "X"; break;
				case 11: return "XI"; break;
				case 12: return "XII"; break;
			}
			return "" + num;
		}
		
		public function getTactic(index:int):StrategyTO {
			if(tacticsProvider.length <= 0) return null;
			return tacticsProvider.getItemAt(index) as StrategyTO;
		}
		
		public static function getInstance():StrategyManager {
			return instance;
		}

	}
}